# Build recipe for herbstluftwm
#
# Copyright 2016-2018 Mateus P. Rodrigues <mprodrigues@dragora.org>.
#
# This recipe is free software, under the terms of the Apache License 2.0

program=herbstluftwm
version=0.7.0
release=1

description="
herbstluftwm is a manual tiling window manager for X11 using Xlib and
Glib. Its main features can be described with:

the layout is based on splitting frames into subframes which can
be split again or can be filled with windows (similar to i3/musca).

tags (or workspaces or virtual desktops or …) can be added/removed
at runtime. Each tag contains an own layout.

exactly one tag is viewed on each monitor. The tags are monitor
independent (similar to xmonad).

it is configured at runtime via ipc calls from herbstclient. So
the configuration file is just a script which is run on
startup. (similar to wmii/ musca).
"

homepage=http://herbstluftwm.org/index.html
license="Simplified BSD license"

tarname=${program}-${version}.tar.gz

# Remote source(s)
fetch="http://www.herbstluftwm.org/tarballs/$tarname"

# Source documentation
docs="AUTHORS BUGS HACKING LICENSE MIGRATION NEWS README.md"
docsdir="${docdir}/${program}-${version}"

build() {
    unpack "${tardir}/$tarname"

    cd "$srcdir"
    ./configure CFLAGS="$QICFLAGS" LDFLAGS="$QILDFLAGS" \
    $configure_args \
    --libdir=/usr/lib${libSuffix} \
    --infodir=$infodir \
    --mandir=$mandir \
    --docdir=$docdir \
    --build="$(cc -dumpmachine)"

    make -j${jobs} V=1
    make -j${jobs} DESTDIR="$destdir" install

    # Compress and link man pages (if needed)
    if test -d "${destdir}/$mandir"
    then
        (
            cd "${destdir}/$mandir"
            find . -type f -exec lzip -9 '{}' +
            find . -type l | while read -r file
            do
                ln -sf "$(readlink -- "$file").lz" "${file}.lz"
                rm -- "$file"
            done
        )
    fi

    # Copy documentation
    mkdir -p "${destdir}${docsdir}"
    cp -p $docs "${destdir}${docsdir}"
}
